package com.baizhi.service.impl;

import com.baizhi.dao.CmfzGuruDao;
import com.baizhi.entity.CmfzGuru;
import com.baizhi.service.CmfzGuruService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: renpu
 * @Date: 2019/2/27 22:17
 * @Description:
 */

@Service
@Transactional
public class CmfzGuruServiceImpl implements CmfzGuruService {
    @Autowired
    private CmfzGuruDao guruDao;


    @Override
    public Map selectByPage(int rows, int page) {
        Map map=new HashMap();
        int start=(page-1)*rows;
        int pagesize=rows;
        int count=guruDao.selectCount();
        List<CmfzGuru> list=guruDao.selectByPage(start,pagesize);
        map.put("rows",list);
        map.put("total",count);
        return map;
    }

    @Override
    public void insertGuru(CmfzGuru guru) {
        guruDao.insertGuru(guru);
    }

    @Override
    public void deleteGuru(int[] ids) {
        for (int id:ids) {
            guruDao.deleteGuru(id);
        }
    }

    @Override
    public List<CmfzGuru> selectAllGuru() {
        return guruDao.selectAllGuru();
    }
}
